package com.sneakxy.mybase4j.base;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;

public class MyBase4jCommonsMultipartResolver extends CommonsMultipartResolver {

	@Override
	public boolean isMultipart(HttpServletRequest request) {
		String uri = request.getRequestURI();
		//解决ueditor与spring冲突问题
		if(StringUtils.contains(uri, "/ueditor") 
				&& StringUtils.equals("snapscreen", request.getParameter("action"))) {
			return false;
		}
		return super.isMultipart(request);
	}

	public ServletFileUpload getServletFileUpload(HttpServletRequest request) {
		String encoding = determineEncoding(request);
		return (ServletFileUpload) prepareFileUpload(encoding);
	}
	
}
